﻿using System;
using System.Collections.Generic;
using BotonJXC.Entity;
using InPayItemDAO = BotonJXC.DAO.InPayItemDAO;
using BotonJXC.Util;
using NHibernate.Criterion;

namespace BotonJXC.BLL
{
    public class InPayItemBLL : BaseBLL<InPayItemDAO, InPayItem, int>
    {
        public InPayItemBLL()
        {
        }

        public PageModel<InPayItem> Find(string itemName, string code, short itemType, int start, int count)
        {
            List<ICriterion> criterions = new List<ICriterion>();
            if (!string.IsNullOrEmpty(itemName))
            {
                criterions.Add(Restrictions.Like("ItemName", itemName, MatchMode.Anywhere));
            }
            if (!string.IsNullOrEmpty(code))
            {
                criterions.Add(Restrictions.Eq("Code", code));
            }
            if (itemType > 0)
            {
                criterions.Add(Restrictions.Eq("ItemType", itemType));
            }
            criterions.Add(Restrictions.Eq("Enabled", "Y"));
            return Dao.FindByPage(criterions.ToArray(), null, start, count);
        }
    }
}